<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>修改密码</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/global.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>

    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
        .l{
		   width: 100%;
		   height: 1px;
		   background: #000;
		   display: block;
		   float: left;
		   margin-top: 16px;
		   margin-bottom: 10px;
		}
		.lable{
			font-size: 16px;
			width: 10%;
			float:left;
		}
		.h1{
			margin-top: 0px;
			width: 80%;
    		font-size: 20px !important;
		}
		.left ul li{
			
			*line-height:40px;
			
			*padding-left:20px;
		}
		
		.left ul li a, .left ul li a:hover{
			*color:#fff;
		}
		.jqGrid_wrapper{
			*margin-left:270px;
			padding-top:30px\9;
			*+padding-top:10px;
		}
		.form-group{
			*overflow: hidden;
		}
		
		.lt{
			float:left;
		}
		.form-group label{
			width:250px\9;
			*+width:200px;
			text-align:right\9;
			*+text-align:right;
		}
		.col-sm-8 input{
			width:680px\9;
			*+width:680px;
			*+height:26px;
		}
    </style>
</head>
<body view="menu-item-4142">
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
    <div style="width: 150px;*+margin-left:260px;">
        <label class="lable" style="width: 150px;">修改用户登录密码:</label>
    </div>
	<div class="jqGrid_wrapper">
		<div class="col-sm-12">
		    <form class="form-horizontal m-t" id="uploadForm">
		         <input type="hidden" name="sid" id="sid" value="${user.sid}">
		        <div class="form-group">
		            <label class="col-sm-3  control-label lt">账号:</label>
		            <div class="col-sm-8 lt">
		                <input class="form-control" readonly name="userName"  value="${user.userName}" size="30"/>
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-sm-3  control-label lt"><i class="require">*</i>原密码:</label>
		            <div class="col-sm-8 lt">
		                 <input class="form-control" type="password" name="oldPassword" id="oldPassword"  size="30" />
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-sm-3  control-label lt"><i class="require">*</i>新密码:</label>
		            <div class="col-sm-8 lt">
		                    <input class="form-control" type="password" name="newPassword" id="newPassword" size="30" />
		            </div>
		        </div>
		        <div class="form-group">
		            <label class="col-sm-3  control-label lt"><i class="require">*</i>确认密码:</label>
		            <div class="col-sm-8 lt">
		                    <input class="form-control" type="password" name="againPassword" id="againPassword"  size="30" />
		            </div>
		        </div>
		        
		        <div style="text-align: center;">
		             <input class="btn btn-success form-control"  type="button" id="sub" onclick="checkTail()"  style="width: 150px;" value="提交">
		        </div>
		 </form>
		</div>
	</div>
</div>
<script type="text/javascript">

function checkTail(){
	$("#sub").attr("disabled", "true");
	var sid = $("#sid").val();
	var oldPassword = $("#oldPassword").val();
    var newPassword = $("#newPassword").val();
    var againPassword = $("#againPassword").val();
    if(!oldPassword){
      	 alert("原密码必填");
      	 $("#sub").removeAttr("disabled");
      	 return;
     }else if(!(/^[A-Za-z_0-9\x21-\x7e]{6,16}$/.test(oldPassword))){
      	 alert("原密码有误，请填写6-16位，字母、数字或英文符号"); 
         $("#sub").removeAttr("disabled");
         return; 
     }
    if(!newPassword){
   	 	alert("新密码必填");
   	 	$("#sub").removeAttr("disabled");
   	 	return;
    }else if(!(/^[A-Za-z_0-9\x21-\x7e]{6,16}$/.test(newPassword))){
   	 	alert("新密码有误，请填写6-16位，字母、数字或英文符号"); 
        $("#sub").removeAttr("disabled");
        return; 
   	}
   	if(!againPassword){
   		alert("确认密码必填");
  		$("#sub").removeAttr("disabled");
  	 	return;
   	}else if(newPassword != againPassword){
  	 	alert("确认密码和登录密码不匹配"); 
    	$("#sub").removeAttr("disabled");
    	return; 
	}
    $.post("${pageContext.request.contextPath}/admin/sysopt_updatePassword.action", {
        'sid':sid,
        'oldPassword':oldPassword,
	    'newPassword': newPassword
     }, function (result) {
         result = JSON.parse(result)
         if (result.code == 1) {
        	 layer.alert(result.msg);
        	 $("#sub").removeAttr("disabled");
         }else{
        	 $("#sub").removeAttr("disabled");
         	layer.alert(result.msg);
         }
     });
}
</script>
</body>
</html>
